package org.sai.wxnovel.controller;

import org.sai.wxnovel.bean.Genres;
import org.sai.wxnovel.bean.PageInfo;
import org.sai.wxnovel.service.BookService;
import org.sai.wxnovel.service.GenresService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/genres")
public class GenresController {
    @Autowired
    private BookService bookService;

    @Autowired
    private GenresService genresService;

    @RequestMapping("/list.sai")
//    方法名随便取
    public String fdsagdf(Integer id, Model model,Integer pageNum,Integer pageSize){
        model.addAttribute("genres",genresService.getGenresById(id));
        model.addAttribute("booksOfGenres",bookService.getBooksOfGenres(id,pageNum,pageSize));
        PageInfo pageInfo=new PageInfo(bookService.getCountOfGenres(id),pageNum,pageSize);
        model.addAttribute("pageInfo",pageInfo);
        return "genreslist";
    }
}
